import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'
import i18n from './lang'
import ElementUI from 'element-ui';
import './permission' // permission control
import 'element-ui/lib/theme-chalk/index.css';
import VueAwesomeSwiper from 'vue-awesome-swiper'
// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

function getUrlParams() {
         var url = window.location.href
          var params = {};
          url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str, key, value) {
              params[key] = value;
          });
          return params;
      }
Vue.prototype.$getUrlParams = getUrlParams
// 限制小数点后2位
Vue.prototype.$geShi = function (ob) {
        ob = ob.replace(/[^\d.]/g,""); // 清除"数字"和"."以外的字符
        ob = ob.replace(/^\./g,""); // 验证第一个字符是数字而不是.
        ob = ob.replace(/\.{2,}/g,"."); // 只保留第一个. 清除多余的
        ob = ob.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        ob = ob.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); // 只能输入两个小数
        if (ob.indexOf(".") < 0 && ob !== "") {//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的数字
            ob = parseFloat(ob);
        }
        return ob
    }
Vue.use(VueAwesomeSwiper)
Vue.use(VueQuillEditor)
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
});
Vue.$message = Element.Message
Vue.config.productionTip = false
new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')
